package com.shexianyu.controller;

import com.shexianyu.entity.Info;
import com.shexianyu.service.InfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author shexianyu
 * @desc
 * @date 2022/1/19
 */
@Slf4j
@RestController
public class TestController {

    @Resource
    private InfoService infoService;

    @GetMapping(value = "get")
    public String findById(Long id) {
        Info info = infoService.findById(1);
        log.info("info:" + info);
        Info cached = infoService.findById(1);
        log.info("cached:" + cached);
        info = infoService.findById(2);
        log.info("info:" + info);
        return "ok";
    }

    @GetMapping("/delete")
    public String delete(long id) {
        infoService.deleteFromCache(id);
        return "ok";
    }

    @GetMapping("/test")
    public String test() {
        infoService.test();
        return "ok";
    }
}
